package com.fbee.smartcommunities.service;

import com.fbee.smartcommunities.entity.UploadFile;
import com.baomidou.mybatisplus.extension.service.IService;
import io.minio.errors.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * <p>
 * 文件表 服务类
 * </p>
 *
 * @author 汪佳泉
 * @since 2024-08-16
 */
public interface UploadFileService extends IService<UploadFile> {

    /**
     * 通过这三个参数来获取图片，目的是防止将重复的图片上传到服务器上面去。
     * @param md5
     * @param size
     * @param contentType
     * @return
     */
    UploadFile get(String md5,Long size,String contentType);

    /**
     * 保存图片到服务器中，并将图片路径保存到实体的字段中去
     * @param bucket
     * @param file
     * @return
     */
    String upload(String bucket, MultipartFile file) throws IOException, ServerException, InsufficientDataException, ErrorResponseException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException;

}
